package nioTest;

import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.locks.ReadWriteLock;
import java.util.concurrent.locks.ReentrantReadWriteLock;

public class test {

    private static final AtomicBoolean atomicBoolean = new AtomicBoolean(false);

    public static void main(String[] args) {
        ByteBuf buf = Unpooled.buffer();
        buf.writeByte(126);

        byte[] tBytes = new byte[buf.writerIndex()];
        buf.getBytes(0, tBytes);

        ByteBuf buf2 = Unpooled.wrappedBuffer(tBytes);

        System.out.println(buf2.readByte());
        System.out.println(0 << 0);
        System.out.println(1 << 0);
        System.out.println(1 << 2);
        System.out.println(1 << 3);
        System.out.println(1 << 4);

        System.out.println(1 & 8);
        System.out.println(8 & 8);
        System.out.println(1 & 4);
        System.out.println(1 | 4);
        System.out.println(1 | 16);
        System.out.println(1 & (1 | 16));



        System.out.println(1 << 5);
        System.out.println(1 << 6);
        System.out.println(1 << 7);
        System.out.println(1 << 8);
        System.out.println(1 << 30);

        System.out.println(1 >>> 32);
        System.out.println(1 & 32);
        int count = 0;
//        List<String> kk = new ArrayList<>();
//        for (int i = 0; i < count; i++) {
//            kk.add(String.valueOf(i));
//        }
//        int pageSize = 2;
//        int page = count % pageSize == 0 ? count / pageSize : count / pageSize + 1;
//        for (int i = 0; i < page; i++) {
//            int start = i * pageSize;
//            int tempEnd = (i + 1) * pageSize;
//            int end = tempEnd > count ? count : tempEnd;
//            List<String> strings = kk.subList(start, end);
//            List<String> accountList = new ArrayList<>();
//            for (String pushAccountVO : strings) {
//                accountList.add(pushAccountVO);
//            }
//            System.out.println(accountList + "111");
//        }

        int pageSize = 2000;
        Integer maxPlayerId = 465980;
        int minPlayerId = 400000;
        long playerCount = maxPlayerId - minPlayerId;
        long pageCount = playerCount % pageSize == 0 ? playerCount / pageSize : playerCount / pageSize + 1;
        for (int i = 0; i < pageCount; i++) {
            int start = minPlayerId + i * pageSize;
            int tempEnd = minPlayerId + (i + 1) * pageSize - 1;
            long end = (i + 1) == pageCount ? maxPlayerId : tempEnd;
            System.out.println("start = " + start + "; end = " + end);
        }
    }
}
